<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>vue 复习</title>
    <!--Staticfile CDN（国内）-->
    <!--<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>-->
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
    <style>

    </style>
</head>
<body>


<script>






//淘宝的
    //id="J_SmallSubmit"
    let time = setInterval(function(){
        let J_LinkBuy = document.getElementById('J_SmallSubmit')
        if(J_LinkBuy){
            clearInterval(time)
            J_LinkBuy.click()
        }
    },1)


    //一直刷新
    //设定开抢时间
    const falgTime = new Date('2020-12-19 20:00:00')
    //开启定时器扫描
    let timer = setInterval(function(){
        //获取当前实时时间
        let currentTime = new Date()
        //转字符串类型比较，当到达开抢时间立即执行结算事件
        if(currentTime+'' === falgTime+''){
            //清除定时器
            clearInterval(timer)
            let J_LinkBuy = document.getElementById('J_SmallSubmit')
            if(J_LinkBuy){

                //自动执行点击购物车结算
                J_LinkBuy.click()
            }
        }
    },1)

</script>
<input type="text" name="name">
<input type="text" name="age">
<button onclick="setSession()">set session</button>
<button onclick="getSession()">get session</button>
<div id="showValue"></div>
<img width="300" src=""/>
<script>
    let name = document.querySelector('[name="name"]')
    let age = document.querySelector('[name="age"]')
    let showValue = document.getElementById('showValue')

    function setSession(){

        let user ={}
        user.name = name.value
        user.age =  age.value
        console.log(user)
        if(user){
            sessionStorage.setItem("user", JSON.stringify(user))
            getSession()
        }

    }

    function getSession(){
        let  curUser = sessionStorage.getItem("user");
        if(!curUser)return null;
        curUser  = JSON.parse(curUser)
        showValue.innerHTML = curUser.name + ' ' + curUser.age
    }
    getSession()
</script>
</body>
</html>